expect_stdin: Option<String>,
expect_stderr: Option<String>,
expect_exit_code: Option<i32>,
- expect_stdout_contains: Vec<String>
+ expect_stdout_contains: Vec<String>,
+ expect_stderr_contains: Vec<String>,
}
impl Execs {
-
pub fn with_stdout<S: ToString>(mut self, expected: S) -> Execs {
self.expect_stdout = Some(expected.to_string());
self
self
}
+ pub fn with_stderr_contains<S: ToString>(mut self, expected: S) -> Execs {
+ self.expect_stderr_contains.push(expected.to_string());
+ self
+ }
+
fn match_output(&self, actual: &Output) -> ham::MatchResult {
self.match_status(actual)
.and(self.match_stdout(actual))
try!(self.match_std(Some(expect), &actual.stdout, "stdout",
&actual.stderr, true));
}
+ for expect in self.expect_stderr_contains.iter() {
+ try!(self.match_std(Some(expect), &actual.stderr, "stderr",
+ &actual.stdout, true));
+ }
Ok(())
}
expect_stderr: None,
expect_stdin: None,
expect_exit_code: None,
- expect_stdout_contains: vec![]
+ expect_stdout_contains: Vec::new(),
+ expect_stderr_contains: Vec::new(),
}
}
assert_that(p.cargo_process("build"),
execs()
.with_status(101)
- .with_stderr("\
+ .with_stderr_contains("\
src[..]foo.rs:1:1: 1:8 error: expected item[..]found `invalid`
src[..]foo.rs:1 invalid rust code!
^~~~~~~
+")
+ .with_stderr_contains("\
Could not compile `foo`.
To learn more, run the command again with --verbose.\n"));